package com.easondongh.spring.service;

import org.springframework.beans.TypeConverter;
import org.springframework.beans.TypeMismatchException;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;

import java.lang.reflect.Field;

/**
 * @author donghao
 * @date 2022/2/5 1:11
 */
@Component
public class CustomTypeConverter implements TypeConverter {

    @Override
    public <T> T convertIfNecessary(Object value, Class<T> requiredType) throws TypeMismatchException {
//        if (requiredType.isAssignableFrom(OrderService.class)) {
//            return (T) new OrderService();
//        }
        return null;
    }

    @Override
    public <T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam) throws TypeMismatchException {
        return null;
    }

    @Override
    public <T> T convertIfNecessary(Object value, Class<T> requiredType, Field field) throws TypeMismatchException {
        return null;
    }
}
